#include "GunBottomEntity.h"
GunBottomEntity::GunBottomEntity(int id, int type, double x, double y)
{
	_data = new BossData(id, type, x, y, STATE_MAP_STATE1_BOSS_GUN_BOTTOM);
	life = 10;
	_data->canInteract = false;
	delayForNext = 0;
}

void GunBottomEntity::update(long time)
{
	if (_data->isDead) {
		delayForNext--;
		if (delayForNext == 0) {
			GameDeviceSingleton::getInstance()->setCurrentMapLevel(2);
		}
	} else {
		_data->sprites->updateCurrent();
	}
}

void GunBottomEntity::draw(long time){
	if (_data->isDead) return;
	_data->sprites->draw();
}

/*Return object data*/
AbstractData* GunBottomEntity::getAbstractData()
{
	return _data;
}

GunBottomEntity::~GunBottomEntity()
{}

void GunBottomEntity::updateData(int action, int actiondata) {
	if (action == ACTIONS_IS_HURT) {
		life -= actiondata;
		if (life < 0 && !_data->isDead) {
			_data->isDead = true;
			_data->canInteract = false;
			EffectManager::getInstatnse()->createEffect(EffectType::TYPE_Bridge_Fier, 
				_data->getRect()->X, _data->getRect()->Y);
			delayForNext = 50;
		}
	}
}